package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TtopicDao;
import com.xy.manage.model.Ttopic;
import com.xy.manage.service.TtopicService;

@Service
@Transactional
public class TtopicServiceImpl extends BaseServiceImpl<Ttopic> implements
		TtopicService {
	private TtopicDao ttopicDao;

	public TtopicServiceImpl(TtopicDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.ttopicDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return ttopicDao.checkExist("Ttopic", paraName, paraValue);
	}

	@Override
	public List<Ttopic> getTtopic(Map<String, Object> map) {
		return ttopicDao.getTtopic(map);
	}
	@Override
	public Pagination getTtopicByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return ttopicDao.getTtopicByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Ttopic save(Ttopic ttopic) {
	//	ttopic.setModtime(new Date());
		if(ttopic.getTid()==null){
			//新增
        	return super.save(ttopic);
		}else{
			//更新
			Ttopic ttopic1=ttopicDao.get(ttopic.getTid());
			try {
				BeanUtil.copyNotNullProperties(ttopic1, ttopic);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(ttopic1);
		}
	}
}